<template>
  <view>
    <view class="list-container">
      <!-- 检查信息 -->
      <view class="item">
        <view class="top-label" @click="retract(0)">
          <view>检查信息</view>
          <view v-if="showBasicInformation[0].show"><uv-icon name="arrow-down" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
        </view>
        <view class="info" v-if="showBasicInformation[0].show">
          <view class="row">
            <view class="title">检查地点:</view>
            <view class="con">{{ law.canteenId ?law.canteenName:law.schoolName}}</view>
          </view>
          <view class="row">
            <view class="title">指标名称:</view>
            <view class="con">{{ law.targetName }}</view>
          </view>
          <view class="row">
            <view class="title">检查日期:</view>
            <view class="con">{{ law.lawDate }}</view>
          </view>
          <view class="row">
            <view class="title">检查人:</view>
            <view class="con">{{ law.userName||"--" }}</view>
          </view>
        </view>
      </view>
      <!-- 检查内容 -->
      <view class="item">
        <view class="top-label" @click="retract(1)">
          <view>检查内容</view>
          <view v-if="showBasicInformation[1].show"><uv-icon name="arrow-down" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
        </view>
        <view class="info">
          <DaTree
              v-show="showBasicInformation[1].show"
              ref="DaTreeRef"
              :data="roomTreeData"
              labelField="content"
              valueField="id"
              defaultExpandAll
              :show-annotation="true"
              :show-control="false"
              :show-annotation-look="true"
          >
          </DaTree>
        </view>
      </view>
      <!-- 检查图片 -->
      <view class="item">
        <view class="top-label" @click="retract(2)">
          <view>检查照片</view>
          <view v-if="showBasicInformation[2].show"><uv-icon name="arrow-down" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
        </view>
        <view v-show="showBasicInformation[2].show">
          <view class="info">
            <view class="img-all">
              <fileUpload :tableId="law.id" tableName="sup_law_item" type="photo" :watermarkFlag="true"
                          :maxCount="0" :deletable="false" width="72" height="72"/>
            </view>
          </view>
        </view>
      </view>
      <!-- 检查记录单 -->
      <view class="item">
        <view class="top-label" @click="retract(3)">
          <view>检查记录单</view>
          <view v-if="showBasicInformation[3].show"><uv-icon name="arrow-down" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
        </view>
        <view v-show="showBasicInformation[3].show">
          <view class="info">
            <view class="img-all">
              <view v-if="billImage.length === 0">--</view>
              <fileUpload :tableId="law.id" tableName="sup_law_item" type="bill" :watermarkFlag="true"
                          :maxCount="0" :deletable="false" width="72" height="72" @initImage="initBillImage"/>
            </view>
          </view>
        </view>
      </view>
      <!-- 检查情况补充 -->
      <view class="item" v-if="!(law.entryType == '3' || law.entryType == '4' || law.entryType == '5' || law.entryType == '8')">
        <view class="top-label" @click="retract(4)">
          <view>检查情况补充</view>
          <view v-if="showBasicInformation[4].show"><uv-icon name="arrow-down" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
        </view>
        <view class="info" v-if="showBasicInformation[4].show" style="margin-left: 10rpx;word-wrap: break-word;">
          {{lawItem.checkRecord ||'--'}}
        </view>
      </view>
      <!-- 是否需要整改 -->
      <view class="item" v-if="law.entryType == '3' || law.entryType == '4'  || law.entryType == '5' || law.entryType == '8'">
        <view class="zheng-gai">
          <view class="top-label">
            <view>自查结果</view>
            <view v-if="law.rectifyFlag == 0" style="color: #18A400;font-size: 28rpx;">{{'合格'}}</view>
            <view v-else style="color:  #FF0000;font-size: 28rpx;">{{'不合格'}}</view>
          </view>
          <view v-if="law.rectifyFlag != 0">
            <view class="zheng-gai-zi">整改意见：</view>
            <view class="info">{{lawItem.rectificationContent||'--'}}</view>
          </view>
        </view>
      </view>
      <view class="item" v-else>
        <view class="zheng-gai">
          <view class="top-label">
            <view>是否需要整改</view>
            <view style="color: #949494;font-size: 28rpx;">{{law.rectifyFlag == 0 ?'否':'是'}}</view>
          </view>
          <view>
            <view class="zheng-gai-zi">整改意见：</view>
            <view class="info">{{lawItem.rectificationContent||'--'}}</view>
          </view>
        </view>
      </view>
      <!--自查整改照片-->
      <view class="item" v-if="(law.entryType == 3 || law.entryType == 4  || law.entryType == 5 || law.entryType == '8') && law.rectifyFlag ==1">
        <view class="top-label" @click="retract(5)">
          <view>自查整改照片</view>
          <view v-if="showBasicInformation[5].show"><uv-icon name="arrow-down" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="rgba(0, 0, 0, 0.4)"></uv-icon></view>
        </view>
        <view v-show="showBasicInformation[5].show">
          <view class="info">
            <view class="img-all">
              <fileUpload :tableId="law.id" tableName="sup_law_item" type="rectify" :watermarkFlag="true"
                          :maxCount="0" :deletable="false" width="72" height="72"/>
            </view>
          </view>
        </view>
      </view>
      <!-- 检查人签名 -->
      <view class="item">
        <view class="top-label">
          <view>检查人签名</view>
          <view>
            <image v-if="law.entryType == 3 || law.entryType == 4 || law.entryType == 5 || law.entryType == '8'" class="img-sign" :src="law.caterSign"/>
            <image v-else class="img-sign" :src="law.superviseSign"/>
          </view>
        </view>
      </view>
      <!-- 审核信息 -->
      <view class="item" v-if="null != lawItem.lawItem">
        <view class="top-label">
          <view>审核信息</view>
        </view>
        <view class="info">
          <view class="row">
            <view class="title">审核结果:</view>
            <view class="con">{{ lawItem.lawItem.lawFlag==1 ?"审核通过":"审核不通过"}}</view>
          </view>
          <view class="row" v-if="lawItem.lawItem.lawFlag==0">
            <view class="title">审核意见:</view>
            <view class="con">{{ lawItem.lawItem.reason }}</view>
          </view>
          <view class="row">
            <view class="title">审核时间:</view>
            <view class="con">{{ lawItem.lawItem.lawDate }}</view>
          </view>
          <view class="row">
            <view class="title">审核人:</view>
            <view class="con">{{ lawItem.lawItem.userName }}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import {ref, reactive, defineProps, getCurrentInstance} from 'vue';
import api from '@/api/law/lawBindEntry/lawBindEntry'
const showBasicInformation = reactive([{ show: true }, { show: true }, { show: true }, { show: true }, { show: true }, { show: true }]);
const DaTreeRef = ref()
const roomTreeData = ref([])
const props = defineProps({
  law: {
    type: Object,
    default:{
      targetId:'',
      targetName:'',
      schoolId:'',
      schoolName:'',
      canteenId:'',
      canteenName:'',
      userId:'',
      userName:'',
      lawDate:'',
      entryType:'',
      lawStatus:'',
      rectifyFlag:0,
      rectifyStatus:'',
      auditName:'',
      auditDate:null,
      reviewName:'',
      reviewDate:null,
      lawType:'',
      superviseSign:'',
      caterSign:'',
      createOrgName:'',
    },
    required:true
  },
  lawItem:{
    type: Object,
    default:{
      lawItem:null,
      checkRecord:"",
      rectificationContent:'',

    },
    required:true
  },
});
const {proxy} = getCurrentInstance()
let retract=(index)=> {
  showBasicInformation[index].show = !showBasicInformation[index].show;
}
let getList = async ()=>{
  let res = await proxy.http.asyncPost(api.lawBindEntryTree(props.law.id))
  roomTreeData.value = res.data
}
getList()
let billImage = ref([]);
let initBillImage = (imageList, type) => {
  billImage.value = imageList
}
</script>

<style lang="scss" scoped>
//公用样式文件
@import "@/static/css/packageBase/smain.scss";
@import "@/static/css/packageBase/lmain.scss";
//日常检查样式
@import "@/static/css/dailycheck/dailycheck.scss";
@import "@/static/css/dailycheck/viewIndex.scss";
</style>
